# TODO
# - test output

#
# Data for External Tests
#
$(for i=1,#tests do
OUT=OUT..[[
ExternalData_Expand_Arguments( SimpleITKData
  unused_argument]]
for j=1,#tests[i].inputs do
  OUT=OUT..[[
  "DATA{$${SimpleITK_DATA_ROOT}/]]..tests[i].inputs[j]..[[}"
]]
end
if tests[i].tolerance then
  OUT=OUT..[[
  "DATA{$${SimpleITK_DATA_ROOT}/Baseline/BasicFilters_${name}_]]..tests[i].tag..[[.nrrd,:}"
]]
end
OUT=OUT..[[
)
]]
end)


#
# Lua Tests
#
$(for i=1,#tests do
local script = [["$${SimpleITK_BINARY_DIR}/Testing/Unit/LuaTests/${name}Test.lua"]]
local output = [["$${SimpleITK_TEST_OUTPUT_DIR}/Lua-${name}-]]..tests[i].tag..[[.nrrd"]]
local baseline = [["DATA{$${SimpleITK_DATA_ROOT}/Baseline/BasicFilters_${name}_]]..tests[i].tag..[[.nrrd,:}"]]
OUT=OUT..[[
 sitk_add_lua_test( ${name}.]]..tests[i].tag..[[
  ]]..script..[[
  ]]..tests[i].tag..[[
]]
for j=1,#tests[i].inputs do
    OUT=OUT..[[
  "DATA{$${SimpleITK_DATA_ROOT}/]]..tests[i].inputs[j]..[[}"
]]
end
OUT=OUT..[[
  ]]..output
if tests[i].md5hash then
  OUT=OUT..[[
    IMAGE_MD5_COMPARE ]]..output..[[ ]]..tests[i].md5hash
end
if tests[i].tolerance then
   OUT=OUT..[[
    IMAGE_COMPARE ]]..output..[[ ]]..baseline..[[ ]]..tests[i].tolerance
end
OUT=OUT..[[ )
]]
end)


#
# Python Tests
#
$(for i=1,#tests do
local script = [["$${SimpleITK_BINARY_DIR}/Testing/Unit/PythonTests/${name}Test.py"]]
local output = [["$${SimpleITK_TEST_OUTPUT_DIR}/Python-${name}-]]..tests[i].tag..[[.nrrd"]]
local baseline = [["DATA{$${SimpleITK_DATA_ROOT}/Baseline/BasicFilters_${name}_]]..tests[i].tag..[[.nrrd,:}"]]
OUT=OUT..[[
 sitk_add_python_test( ${name}.]]..tests[i].tag..[[
   ]]..script..[[
   ]]..tests[i].tag
for j=1,#tests[i].inputs do
  OUT=OUT..[[
  "DATA{$${SimpleITK_DATA_ROOT}/]]..tests[i].inputs[j]..[[}"]]
end
OUT=OUT..[[
  ]]..output
if tests[i].md5hash then
  OUT=OUT..[[
    IMAGE_MD5_COMPARE ]]..output..[[ ]]..tests[i].md5hash
end
if tests[i].tolerance then
   OUT=OUT..[[
    IMAGE_COMPARE ]]..output..[[ ]]..baseline..[[ ]]..tests[i].tolerance
end
OUT=OUT..[[ )
]]
end)

#
# Ruby Tests
#
$(for i=1,#tests do
local script = [["$${SimpleITK_BINARY_DIR}/Testing/Unit/RubyTests/${name}Test.rb"]]
local output = [["$${SimpleITK_TEST_OUTPUT_DIR}/Ruby-${name}-]]..tests[i].tag..[[.nrrd"]]
local baseline = [["DATA{$${SimpleITK_DATA_ROOT}/Baseline/BasicFilters_${name}_]]..tests[i].tag..[[.nrrd,:}"]]
OUT=OUT..[[
 sitk_add_ruby_test( ${name}.]]..tests[i].tag..[[
  ]]..script..[[
  ]]..tests[i].tag..[[
]]
for j=1,#tests[i].inputs do
    OUT=OUT..[[
  "DATA{$${SimpleITK_DATA_ROOT}/]]..tests[i].inputs[j]..[[}"
]]
end
OUT=OUT..[[
  ]]..output
if tests[i].md5hash then
  OUT=OUT..[[
    IMAGE_MD5_COMPARE ]]..output..[[ ]]..tests[i].md5hash
end
if tests[i].tolerance then
   OUT=OUT..[[
    IMAGE_COMPARE ]]..output..[[ ]]..baseline..[[ ]]..tests[i].tolerance
end
OUT=OUT..[[ )
]]
end)

#
# R Tests
#
$(for i=1,#tests do
local script = [["$${SimpleITK_BINARY_DIR}/Testing/Unit/RTests/${name}Test.R"]]
local output = [["$${SimpleITK_TEST_OUTPUT_DIR}/R-${name}-]]..tests[i].tag..[[.nrrd"]]
local baseline = [["DATA{$${SimpleITK_DATA_ROOT}/Baseline/BasicFilters_${name}_]]..tests[i].tag..[[.nrrd,:}"]]
OUT=OUT..[[
 sitk_add_r_test( ${name}.]]..tests[i].tag..[[
  ]]..script..[[
  ]]..tests[i].tag..[[
]]
for j=1,#tests[i].inputs do
    OUT=OUT..[[
  "DATA{$${SimpleITK_DATA_ROOT}/]]..tests[i].inputs[j]..[[}"
]]
end
OUT=OUT..[[
  ]]..output
if tests[i].md5hash then
  OUT=OUT..[[
    IMAGE_MD5_COMPARE ]]..output..[[ ]]..tests[i].md5hash
end
if tests[i].tolerance then
   OUT=OUT..[[
    IMAGE_COMPARE ]]..output..[[ ]]..baseline..[[ ]]..tests[i].tolerance
end
OUT=OUT..[[ )
]]
end)

#
# Tcl Tests
#
$(for i=1,#tests do
local script = [["$${SimpleITK_BINARY_DIR}/Testing/Unit/TclTests/${name}Test.tcl"]]
local output = [["$${SimpleITK_TEST_OUTPUT_DIR}/Tcl-${name}-]]..tests[i].tag..[[.nrrd"]]
local baseline = [["DATA{$${SimpleITK_DATA_ROOT}/Baseline/BasicFilters_${name}_]]..tests[i].tag..[[.nrrd,:}"]]
OUT=OUT..[[
 sitk_add_tcl_test( ${name}.]]..tests[i].tag..[[
  ]]..script..[[
  ]]..tests[i].tag..[[
]]
for j=1,#tests[i].inputs do
    OUT=OUT..[[
  "DATA{$${SimpleITK_DATA_ROOT}/]]..tests[i].inputs[j]..[[}"
]]
end

OUT=OUT..[[
  ]]..output
if tests[i].md5hash then
  OUT=OUT..[[
    IMAGE_MD5_COMPARE ]]..output..[[ ]]..tests[i].md5hash
end
if tests[i].tolerance then
   OUT=OUT..[[
    IMAGE_COMPARE ]]..output..[[ ]]..baseline..[[ ]]..tests[i].tolerance
end
OUT=OUT..[[ )
]]
end)


#
# Java Tests
#
$(for i=1,#tests do
local script = [["$${SimpleITK_BINARY_DIR}/Testing/Unit/JavaTests/${name}Test.java"]]
local output = [["$${SimpleITK_TEST_OUTPUT_DIR}/Java-${name}-]]..tests[i].tag..[[.nrrd"]]
local baseline = [["DATA{$${SimpleITK_DATA_ROOT}/Baseline/BasicFilters_${name}_]]..tests[i].tag..[[.nrrd,:}"]]
OUT=OUT..[[
 sitk_add_java_test( ${name}.]]..tests[i].tag..[[
  ]]..script..[[
  ]]..tests[i].tag..[[
]]
for j=1,#tests[i].inputs do
    OUT=OUT..[[
  "DATA{$${SimpleITK_DATA_ROOT}/]]..tests[i].inputs[j]..[[}"
]]
end
OUT=OUT..[[
  ]]..output
if tests[i].md5hash then
  OUT=OUT..[[
    IMAGE_MD5_COMPARE ]]..output..[[ ]]..tests[i].md5hash
end
if tests[i].tolerance then
   OUT=OUT..[[
    IMAGE_COMPARE ]]..output..[[ ]]..baseline..[[ ]]..tests[i].tolerance
end
OUT=OUT..[[ )
]]
end)



#
# CSharp Tests
#
$(for i=1,#tests do
local script = [["$${SimpleITK_BINARY_DIR}/Testing/Unit/CSharpTests/${name}Test.cs"]]
local output = [["$${SimpleITK_TEST_OUTPUT_DIR}/CSharp-${name}-]]..tests[i].tag..[[.nrrd"]]
local baseline = [["DATA{$${SimpleITK_DATA_ROOT}/Baseline/BasicFilters_${name}_]]..tests[i].tag..[[.nrrd,:}"]]
OUT=OUT..[[
 sitk_add_csharp_test( ${name}.]]..tests[i].tag..[[
  ]]..script..[[
  ]]..tests[i].tag..[[
]]
for j=1,#tests[i].inputs do
    OUT=OUT..[[
  "DATA{$${SimpleITK_DATA_ROOT}/]]..tests[i].inputs[j]..[[}"
]]
end
OUT=OUT..[[
  ]]..output
if tests[i].md5hash then
  OUT=OUT..[[
    IMAGE_MD5_COMPARE ]]..output..[[ ]]..tests[i].md5hash
end
if tests[i].tolerance then
   OUT=OUT..[[
    IMAGE_COMPARE ]]..output..[[ ]]..baseline..[[ ]]..tests[i].tolerance
end
OUT=OUT..[[ )
]]
end)
